import matplotlib.pyplot as plt
import numpy as np

step =34  # 经过step步到达目标颜色
color_num = step + 1
one = np.ones(color_num)
from_rgb = (240, 255, 11)  # 起始颜色
to_rbg = (15, 8, 96)  # 目标颜色

colors = [((from_rgb[0] + (to_rbg[0] - from_rgb[0]) / step * i),
           (from_rgb[1] + (to_rbg[1] - from_rgb[1]) / step * i),
           (from_rgb[2] + (to_rbg[2] - from_rgb[2]) / step * i))
          for i in range(color_num)]

for index, color in enumerate(colors):
    print(color[0],color[1],color[2],';...')

colors = [((from_rgb[0] + (to_rbg[0] - from_rgb[0]) / step * i) / 255,
           (from_rgb[1] + (to_rbg[1] - from_rgb[1]) / step * i) / 255,
           (from_rgb[2] + (to_rbg[2] - from_rgb[2]) / step * i) / 255)
          for i in range(color_num)]
print(colors)
plt.pie(one, labels=range(color_num), colors=colors)  # colors要求是0-1的浮点数
plt.show()
